
*Additional control for over 40 cohort education

preserve 

keep if age44>40

collapse yos hdegree, by(muni_g)

rename hdegree hdegree_mean_muni
rename yos yos_mean_muni

tempfile control_old
save `control_old'

restore 

drop _merge

joinby muni_g using `control_old', unmatched(master)

gen treat_young=bartik_standardized*(age44<=25)
gen treat_young_hs=bartikhs_st*(age44<=25)
gen treat_young_ls=bartikls_st*(age44<=25)


*Panel B of Table 9

reghdfe hdegree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store hde1
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe hdegree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "No"


estimates store hde2
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe hdegree treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"


estadd local established "Yes"

estimates store hde3
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)





*******************************

reghdfe degree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store de1
sum degree if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe degree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estimates store de2
estadd local established "No"

sum degree if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe degree treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local established "Yes"

estimates store de3
sum degree if vuosi==1970
estadd scalar ymean=r(mean)


*******************************

reghdfe yos treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store yos1
sum yos if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe yos treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estimates store yos2
estadd local established "No"

sum yos if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe yos treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort muni_g ) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local established "Yes"

estimates store yos3
sum yos if vuosi==1970
estadd scalar ymean=r(mean)




labe var treat_young "Exposure x Young"
labe var treat_young_hs "HS Exposure x Young"
labe var treat_young_ls "LS Exposure x Young"


esttab  yos1 yos2 yos3 de1 de2 de3  hde1 hde2 hde3  ///
using "$temp\tables\TABLE_edu_young.tex", ///
mgroups( "Years of Schooling"  "Any degree"  "Higher degree"  , pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
span erepeat(\cmidrule(lr){@span}) ) ///
replace keep(treat_young treat_young_hs treat_young_ls) nonotes ///s
b(%9.3f) se(%9.3f)  stats(N ymean established mfe cfe , fmt(0 3) layout(@ @ @) ///
labels("N"  "Y mean" "Established"    "Muni FE"  "Cohort FE")) label star(* .1 ** .05 *** .01) nodepvars nomtitle


est clear


*Robustness
*control for old cohort edu


reghdfe hdegree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g c.hdegree_mean_muni#age44 muni_g) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store hde1
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe hdegree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g c.hdegree_mean_muni#age44 muni_g) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "No"


estimates store hde2
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe hdegree treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort muni_g c.hdegree_mean_muni#age44 muni_g) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 "\checkmark"
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"


estadd local established "Yes"

estimates store hde3
sum hdegree if vuosi==1970
estadd scalar ymean=r(mean)


*******************************

reghdfe degree treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g c.hdegree_mean_muni#age44) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store de1
sum degree if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe degree treat_young , a(age44 age44#laani50 fem $municontrols_cohort c.hdegree_mean_muni#age44 muni_g ) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estimates store de2
estadd local established "No"

sum degree if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe degree treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort c.hdegree_mean_muni#age44 muni_g ) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local established "Yes"

estimates store de3
sum degree if vuosi==1970
estadd scalar ymean=r(mean)


*******************************

reghdfe yos treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g  c.hdegree_mean_muni#age44 ) cl(muni_g)
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local established "Yes"

estimates store yos1
sum yos if vuosi==1970
estadd scalar ymean=r(mean)

preserve
replace treat_young=bartiknotimber_st*(age44>=5&age44<=25)
reghdfe yos treat_young , a(age44 age44#laani50 fem $municontrols_cohort muni_g  c.hdegree_mean_muni#age44) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estimates store yos2
estadd local established "No"

sum yos if vuosi==1970
estadd scalar ymean=r(mean)
restore 

reghdfe yos treat_young_hs treat_young_ls , a(age44 age44#laani50 fem $municontrols_cohort muni_g  c.hdegree_mean_muni#age44) cl(muni_g)
estadd local mfe "\checkmark"
estadd local cfe "\checkmark"
estadd local controls "\checkmark"
estadd local controls2 ""
estadd local established "Yes"

estimates store yos3
sum yos if vuosi==1970
estadd scalar ymean=r(mean)


labe var treat_young "Exposure x Young"
labe var treat_young_hs "HS Exposure x Young"
labe var treat_young_ls "LS Exposure x Young"


esttab yos1 yos2 yos3 de1 de2 de3   hde1 hde2 hde3   ///
using "$temp\tables\TABLE_edu_young_additional_control.tex", ///
mgroups(  "Years of Schooling"  "Any degree" "Higher degree"   , pattern(1 0 0 1 0 0 1 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) ///
span erepeat(\cmidrule(lr){@span}) ) ///
replace keep(treat_young treat_young_hs treat_young_ls) nonotes ///s
b(%9.3f) se(%9.3f)  stats(N ymean established mfe cfe , fmt(0 3) layout(@ @ @) ///
labels("N"  "Y mean" "Established"    "Muni FE"  "Cohort FE")) label star(* .1 ** .05 *** .01) nodepvars nomtitle



drop treat_young*